home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
wais
/
x
/
scommands.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-09
|
5KB
|
197 lines
/* WIDE AREA INFORMATION SERVER SOFTWARE:
No guarantees or restrictions. See the readme file for the full standard
disclaimer.
This is part of the X user-interface for the WAIS software. Do with it
as you please.
jonathan@Think.COM
*
* $Log: scommands.c,v $
* Revision 1.8 92/04/28 15:30:17 jonathan
* Cleaned up use of scrollists.
*
* Revision 1.7 92/03/17 14:17:00 jonathan
* Generally cleaned up.
*
*/
#ifndef lint
static char *RCSid = "$Header: /tmp_mnt/net/quake/proj/wais/wais-8-b5/x/RCS/scommands.c,v 1.8 92/04/28 15:30:17 jonathan Exp $";
#endif
#define _C_SCOMMANDS
#define XWAIS
#include "xwais.h"
static Boolean editting_new_source;
int last_source = NO_ITEM_SELECTED;
Source edit_source = NULL;
int get_selected_source()
{
return(get_selected_item(sourcewindow->ListWidget));
}
/* widget commands */
/* ARGSUSED */
void
EditSource(w, closure, call_data)
Widget w;
XtPointer closure, call_data;
{
SList s;
char msg[1000];
int CurrentSource;
double_click = FALSE;
LastClicked = w;
if ((CurrentSource = get_selected_source())
!= NO_ITEM_SELECTED) {
if (last_source == CurrentSource) {
if(edit_source == NULL)
edit_source = (Source)s_malloc(sizeof(_Source));
if(!ReadSourceFile(edit_source,
Source_items[CurrentSource],
app_resources.userSourceDirectory))
ReadSourceFile(edit_source,
Source_items[CurrentSource],
app_resources.commonSourceDirectory);
sprintf(msg, "Opening source: %s\n", edit_source->name);
XwaisPrintf(msg);
PopupSource(edit_source);
}
else last_source = CurrentSource;
}
else {
last_source = -1;
XwaisPrintf("No source selected.\nPlease selected one and try again.\n");
}
}
/* ARGSUSED */
void
AddSource(w, closure, call_data)
Widget w;
XtPointer closure, call_data;
{
static Source new = NULL;
double_click = FALSE;
LastClicked = w;
if(new == NULL) {
if((new = (Source) s_malloc(sizeof(_Source))) == NULL) {
fprintf(stderr, "Unable to allocate new source structure.\n");
exit(1);
}
}
editting_new_source = TRUE;
new->name = s_strdup("new.src");
new->directory = s_strdup(app_resources.userSourceDirectory);
strncpy(new->server, "localhost", STRINGSIZE);
strncpy(new->service, "8000", STRINGSIZE);
strncpy(new->database, "database_name", STRINGSIZE);
new->maintainer = s_strdup("");
new->description = s_strdup("");
edit_source = new;
XwaisPrintf("Opening new source\n");
PopupSource(new);
}
void PopupSource(s)
Source s;
{
Arg arglist[10];
Cardinal num_args;
if (s != NULL) {
num_args = 0;
XtSetArg(arglist[num_args], XtNtitle, s->name); num_args++;
XtSetValues(sourcepopup, arglist, num_args);
ReplaceText(snamewid, s->name);
ReplaceText(serverwid, s->server);
ReplaceText(servicewid, s->service);
ReplaceText(dbwid, s->database);
ReplaceText(costwid, s->cost);
ReplaceText(unitwid, s->units);
ReplaceText(maintainerwid, s->maintainer);
ReplaceText(descwid, s->description);
XtPopup(sourcepopup, XtGrabNone);
}
}
/* ARGSUSED */
void CloseSourceEdit(w, closure, call_data)
Widget w;
XtPointer closure, call_data;
{
char name[STRINGSIZE];
Source source;
double_click = FALSE;
LastClicked = w;
if (editting_new_source == TRUE) {
editting_new_source = FALSE;
}
source = edit_source;
if (source != NULL) {
strcpy(name, GetString(snamewid));
if(!((strlen(name) > 4) &&
strstr(name, ".src") &&
(!strcmp(".src", strstr(name, ".src")))))
strcat(name, ".src");
if(source->name != NULL) s_free(source->name);
source->name = s_strdup(name);
if (source->maintainer != NULL) s_free(source->maintainer);
source->maintainer = s_strdup(GetString(maintainerwid));
if (source->description != NULL) s_free(source->description);
source->description = s_strdup(GetString(descwid));
strncpy(source->server, GetString(serverwid), STRINGSIZE);
strncpy(source->service, GetString(servicewid), STRINGSIZE);
strncpy(source->database, GetString(dbwid), STRINGSIZE);
strncpy(source->cost, GetString(costwid), STRINGSIZE);
strncpy(source->units, GetString(unitwid), STRINGSIZE);
WriteSource(app_resources.userSourceDirectory, source, TRUE);
/* ScanDirs(NULL, NULL);*/
}
else XwaisPrintf("No currently selected source. This shouldn't happen.\n");
edit_source = NULL;
XtPopdown(sourcepopup);
}
/* ARGSUSED */
void CancelSourceEdit(w, closure, call_data)
Widget w;
XtPointer closure, call_data;
{
SList s;
double_click = FALSE;
LastClicked = w;
if (editting_new_source == TRUE) {
s = Sources;
editting_new_source = FALSE;
FreeSource(Sources->thisSource);
Sources = Sources->nextSource;
s_free(s);
}
XtPopdown(sourcepopup);
edit_source = NULL;
}